﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using XcoAppSpaces.Dialogs;

namespace test.Dialogs.WinFormsInteraction
{
    public partial class Form1 : Form
    {
        private readonly Dialog dlg;


        public Form1()
        {
            InitializeComponent();

            this.dlg = new Dialog(); // be sure to create dialog here. otherwise the sync context is not yet set!
            this.dlg.Start();
            this.dlg.Handler<int>(ProcessInt, true);
        }


        void ProcessInt(int i)
        {
            this.textBox1.Text = i.ToString();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            this.dlg.Post(new DialogMessage(DateTime.Now.Second, null));
        }
    }
}
